home *** CD-ROM | disk | FTP | other *** search
/ Java 1996 August / Java - Summer 1996.iso / windows / doc / applet / overview / classes / simpleclick.000 < prev    next >
Encoding:
Text File  |  1996-02-26  |  1.8 KB  |  81 lines

  1. <!--NewPage-->
  2. <html>
  3. <head>
  4. <title>SimpleClick.java</title>
  5. </head>
  6. <body>
  7. <p>
  8. <hr size=4>
  9.  
  10. <h2>
  11.     SimpleClick.java
  12. </h2>
  13. <p>
  14. <blockquote>
  15.  
  16. <pre>
  17.  
  18. /*
  19.  * Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved.
  20.  *
  21.  * Permission to use, copy, modify, and distribute this software
  22.  * and its documentation for NON-COMMERCIAL purposes and without
  23.  * fee is hereby granted provided that this copyright notice
  24.  * appears in all copies. Please refer to the file "copyright.html"
  25.  * for further important copyright and licensing information.
  26.  *
  27.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
  28.  * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  29.  * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  30.  * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
  31.  * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
  32.  * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
  33.  */
  34. import browser.Applet;
  35. import awt.Graphics;
  36.  
  37. class SimpleClick extends Applet {
  38.  
  39.     StringBuffer buffer = new StringBuffer();
  40.  
  41.     public void init() {
  42.     resize(500, 20);
  43.         addItem("initializing... ");
  44.     }
  45.  
  46.     public void start() {
  47.         addItem("starting... ");
  48.     }
  49.  
  50.     public void stop() {
  51.         addItem("stopping... ");
  52.     }
  53.  
  54.     public void destroy() {
  55.     addItem("preparing for unloading...");
  56.     }
  57.  
  58.     public void addItem(String newWord) {
  59.     System.out.println(newWord);
  60.     buffer.append(newWord);
  61.     repaint();
  62.     }
  63.  
  64.     public void paint(Graphics g) {
  65.     g.clearRect(0, 0, width, height);
  66.     g.drawRect(0, 0, width - 1, height - 1);
  67.     g.drawString(buffer.toString(), 5, 15);
  68.     }
  69.  
  70.     public void mouseDown(int x, int y) {
  71.     addItem("click!... ");
  72.     }
  73. }
  74. </pre>
  75. </blockquote>
  76. <p>
  77. <hr size=4>
  78. <p>
  79. </body>
  80. </html>
  81.